package com.control.qct.businesssteward.activity;


import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.control.qct.businesssteward.R;
import com.control.qct.businesssteward.adapter.TakeDeliveryListAdapter;
import com.control.qct.businesssteward.base.BaseActivity;
import com.control.qct.businesssteward.entity.TabEntity;
import com.control.qct.businesssteward.model.TakeDeliveryListModel;
import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * 收货
 * Created by Administrator on 2018/1/12 0012.
 */

public class TakeDeliveryActivity extends BaseActivity implements OnTabSelectListener, TakeDeliveryListAdapter
        .ICallbackClickListener {

    @BindView(R.id.ctl_take_delivery_top)
    CommonTabLayout mCtlTakeDeliveryTop;
    @BindView(R.id.rv_take_delivery)
    RecyclerView mRvTakeDelivery;

    private final String[] mTitles = {"全部", "待收货", "已发货", "差异"};
    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private List<TakeDeliveryListModel> mTakeDeliveryListBeanList;
    private List<Integer> mGoodsPicture = new ArrayList<>();
    private TakeDeliveryListAdapter mTakeDeliveryListAdapter;

    public TakeDeliveryActivity() {
        super(R.layout.activity_take_delivery);
    }

    @Override
    protected void initView() {
        setLeftIcon(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        setTitle("收货");
        for (int i = 0; i < mTitles.length; i++) {
            mTabEntities.add(new TabEntity(mTitles[i], 0, 0));
        }
        mCtlTakeDeliveryTop.setTabData(mTabEntities);
        mCtlTakeDeliveryTop.setOnTabSelectListener(this);
        setReplenishmentListBeanList();
        mRvTakeDelivery.setLayoutManager(new LinearLayoutManager(this));
        mTakeDeliveryListAdapter = new TakeDeliveryListAdapter(mTakeDeliveryListBeanList);
        mRvTakeDelivery.setAdapter(mTakeDeliveryListAdapter);
        mTakeDeliveryListAdapter.setCallbackClickListener(this);
        mTakeDeliveryListAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                startActivity(TakeDeliveryOrderActivity.class);
            }
        });
    }

    private void setReplenishmentListBeanList() {
        mTakeDeliveryListBeanList = new ArrayList<>();
        mGoodsPicture.add(R.drawable.icon_placeholder);
        mGoodsPicture.add(R.drawable.icon_placeholder);
        mGoodsPicture.add(R.drawable.icon_placeholder);
        mTakeDeliveryListBeanList.add(new TakeDeliveryListModel("245144", 0, mGoodsPicture, "2018-01-12"));
        mTakeDeliveryListBeanList.add(new TakeDeliveryListModel("245144", 2, mGoodsPicture, "2018-01-13"));
        mTakeDeliveryListBeanList.add(new TakeDeliveryListModel("245144", 1, mGoodsPicture, "2018-01-15"));
        mTakeDeliveryListBeanList.add(new TakeDeliveryListModel("245144", 1, mGoodsPicture, "2018-01-16"));
    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }

    @Override
    public void onClickListener(int position) {
        startActivity(TakeDeliveryOrderActivity.class);
    }
}
